/**
* demo路由
*/
'use strict';
import uiCtrl from './ui'
module.exports = angular.module('app.demo', []).config(function($stateProvider) {
    $stateProvider.state('demo', { //共用layout
        abstract: true,
        url: '/demo',
        templateProvider: function($q) {
            var deferred = $q.defer();
            require.ensure(['../layout.html'], function(require) {
                var template = require('../layout.html');
                deferred.resolve(template);
            }, 'demo-tpl');
            return deferred.promise;
        },
        controller: 'demoCtrl',
        resolve: {
            'app.demo': function($q, $ocLazyLoad) {
                var deferred = $q.defer();
                require.ensure(['./index.js'], function() {
                    var mod = require('./index.js');
                    $ocLazyLoad.load({
                        name: 'app.demo'
                    });
                    deferred.resolve(mod.controller);
                }, 'demo-ctl');
                return deferred.promise;
            }
        }
    }).state('demo.ui', { 
        url: '/ui',
        views: {
            'content': {
                templateProvider: function($q) {
                    var deferred = $q.defer();
                    require.ensure(['./ui/index.html'], function(require) {
                        var template = require('./ui/index.html');
                        deferred.resolve(template);
                    }, 'demo.ui-tpl');
                    return deferred.promise;
                },
                controller:uiCtrl
            }
        },
    })
}).name;
